package edu.sfsu.powerrangers.jeopardy.editor;

import java.awt.BorderLayout;
import javax.swing.JCheckBox;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import edu.sfsu.powerrangers.jeopardy.gamestate.Clue;

public class CluePanel extends JPanel {
	private static final long serialVersionUID = 1L;
	
	private JCheckBox doubleCheck;
	private JTextArea clueField;
	private JTextArea responseField;
	
	public CluePanel() {
		super(new BorderLayout(4,4));
		doubleCheck = new JCheckBox("Daily WTQ");
		doubleCheck.putClientProperty("JComponent.sizeVariant", "mini");
		clueField = new JTextArea();
		clueField.setLineWrap(true);
		clueField.setWrapStyleWord(true);
		JScrollPane cluePane = new JScrollPane(clueField, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
		responseField = new JTextArea();
		responseField.setLineWrap(true);
		responseField.setWrapStyleWord(true);
		JScrollPane responsePane = new JScrollPane(responseField, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
		JTabbedPane crPane = new JTabbedPane();
		crPane.add(cluePane, "Clue");
		crPane.add(responsePane, "Response");
		add(doubleCheck, BorderLayout.PAGE_START);
		add(crPane, BorderLayout.CENTER);
	}
	
	public Clue getClue(int value) {
		return new Clue(value, doubleCheck.isSelected(), clueField.getText(), responseField.getText());
	}
	
	public void setClue(Clue clue) {
		doubleCheck.setSelected(clue.isDouble());
		clueField.setText(clue.getClue());
		responseField.setText(clue.getResponse());
	}
}
